6 Python f-strings tips and tricks
Python's f-strings can do a lot more than you might expect. Learn a few useful tips and tricks in this quick guide.
The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.
Python's f-strings can do a lot more than you might expect. Learn a few useful tips and tricks in this quick guide.
Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.
Converts a string to camelcase.
Converts a given string into a list of words.
Learn two ways to format a string in Python with this quick tip.
Checks if the a value is an empty sequence or collection.
Converts the values of RGB components to a hexadecimal color code.
Using str.lstrip()
to strip a prefix from a string might not be exactly what you're looking for. Here's what you should use instead.
Converts an integer to its roman numeral representation.
Accepts value between 1
and 3999
(both inclusive).
Converts a string to kebab case.
Takes any number of iterable objects or objects with a length property and returns the longest one.
Splits a multiline string into a list of lines.
Converts a string to snake case.
Capitalizes the first letter of a string.
Decapitalizes the first letter of a string.
Check if two iterables are permutations of each other.
Converts a string to a URL-friendly slug.
Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).
Reverses a list or a string.
Learn of the two different ways to convert strings to lowercase in Python and understand when you should use each one with this quick guide.
Here are two quick and elegant ways to check if a string is empty in Python.
Pads a string on both sides with the specified character, if it's shorter than the specified length.
Oftentimes you might need to trim whitespace from a string in Python. Learn of three different way to do this in this short guide.
Checks if the given string is a palindrome.